package com.cxs.schedulecase.job;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Project: scyd-service-ydsearch
 * @Author: cxs2014501@163.com
 * @Create: 2022/7/29 09:25
 * @Description:
 **/
@Slf4j
@Component
public class TestJob extends BaseJob {


    @Override
    public ScheduledJobEnum getScheduledJobEnum() {
        return ScheduledJobEnum.JOB_TEST;
    }

    @Scheduled(cron = "*/5 * * * * ?")
    public void start(){
        execute();
    }


    @Override
    public Boolean beforeExecute() {
        return true;
    }

    @Override
    public void doExecute() {
        long startTime = System.currentTimeMillis();
        try {
            System.out.println("定时任务执行了.....");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            long endTime = System.currentTimeMillis();
            log.info("【定时任务】【{}ms】", endTime - startTime);
        }
    }

    @Override
    public void afterExecute() {

    }
}
